import { createWebHistory, createRouter } from 'vue-router'

import HomeView from '@/views/HomeView.vue'

const routes = [
  // 静态导入，首页这种一般用静态导入
  { path: '/', component: HomeView },
  // 重定向
  { path: '/home', redirect: '/' },
  // 动态导入（路由懒加载）
  { path: '/user', component: () => import('@/views/UserView.vue') },
  // Not found
  {
    path: '/:pathMatch(.*)*',
    name: 'notfound',
    component: () => import('@/views/NotFound.vue'),
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes,
})

export default router
